package com.an;


import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.ChildBeanDefinition;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.sql.DataSource;

//支持事务
@EnableTransactionManagement
@RestController
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class})
@ComponentScan("com.an")
public class SpringBootApp extends SpringBootServletInitializer {

    /**
     * Springboot环境中配置MVC，继承SPring boot提供的初始化器SpringBootServletInitializer
     * 并重写configure()方法
     *
     * @param builder
     * @return
     */

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return builder.sources(SpringBootApp.class);
    }

    @RequestMapping("index")
    public String index() {
//        AbstractApplicationContext
//        BeanDefinition
//        AbstractBeanDefinition

//        ChildBeanDefinition
//        RootBeanDefinition


        System.out.println("crevrv");
        return "hello ";
    }

    public static void main(String[] args) {
        System.out.println("H境中配置MVCello World!");
        System.out.println("H境中配置MVCello World!");
        System.out.println("H境中配置MVCello World!");
        System.out.println("H境中配置MVCello World!");
        System.out.println("H境中配置MVCello World!");
        System.out.println("H境中配置MVCello World!");


        SpringApplication.run(SpringBootApp.class, args);
        System.out.println("Hello World!");
    }


}